package com.zjitc.controller;


import com.zjitc.daomain.User;
import com.zjitc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller("user")
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("/save")
    @ResponseBody
    public String save(){
        userService.save();
        return "{name:1,age:1}";
    }

    @RequestMapping("/save2")
    @ResponseBody
    public User save2(){
        User user=new User();
        user.setAge(1);
        user.setName("name");
        return user;
    }
    @RequestMapping("/select")
    @ResponseBody
    public User select(@RequestParam int id){
        User user=userService.select(id);
        return user;
    }
}
